package com.EM1.www.dao;

import com.EM1.www.util.Connectmysql;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.Date;

public class ConnectExam {
    public void insertExam(int paperId, Date start,Date end,int teacherId,int grade) throws Exception {
        Connection conn = Connectmysql.Connectmysql();
        PreparedStatement pmt = conn.prepareStatement("insert into exam (paper_id,start,end,teacher_id,grade) values (?,?,?,?,?)");
        pmt.setInt(1,paperId);
        pmt.setDate(2, new java.sql.Date(start.getTime()));
        pmt.setDate(3, new java.sql.Date(end.getTime()));
        pmt.setInt(4, teacherId);
        pmt.setInt(5,grade);
        pmt.executeUpdate();
        pmt.close();
    }
}
